package com.xiaobaibai.bo;

import com.xiaobaibai.entity.Product;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;

//购物车
@Data
public class ShoppingCartVo {

    private Integer productId;

    private String productName;

    private String productImage;

    private BigDecimal productPrice;

    private String productUnit;

    private Integer count;

    public static ShoppingCartVo getInstance(Product product){
        ShoppingCartVo shoppingCartVo=new ShoppingCartVo();
        BeanUtils.copyProperties(product,shoppingCartVo);
        shoppingCartVo.setProductImage(product.getProductImage().get(0));
        shoppingCartVo.setProductId(product.getId());
        return shoppingCartVo;
    }

}
